package com.xihua.sx.controller;


import com.xihua.sx.pojo.PageData;
import com.xihua.sx.pojo.Reserve;
import com.xihua.sx.pojo.ReserveSelectLike;
import com.xihua.sx.service.IReserveService;
import com.xihua.sx.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2023-06-16
 */
@RestController
@RequestMapping("/reserve")
public class ReserveController {

    @Autowired
    private IReserveService reserveService;

    /**
     * 分页查询
     * @param pageData
     * @return
     */
    @RequestMapping(value = "/reserveList",method = RequestMethod.GET)
    public ResponseMessage reserveList( PageData pageData){
        System.out.println(pageData.toString());
        return reserveService.reserveList(pageData);
    }

    /**
     * 根据id查询预定信息，测试用的，后期删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/reserveOne",method = RequestMethod.GET)
    public ResponseMessage reserveOne(Integer id){
        return reserveService.reserveOne(id);
    }

    /**
     * 新增车辆预约
     * @param reserve
     * @return
     */
    @RequestMapping(value = "/insertReserve",method = RequestMethod.PUT)
    public ResponseMessage insertReserve(@RequestBody Reserve reserve){
        System.out.println(reserve.toString());
        return reserveService.insertReserve(reserve);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteReserve/{id}",method = RequestMethod.DELETE)
    public ResponseMessage deleteReserve(@PathVariable  Integer id){
        System.out.println(id);
        return reserveService.deleteReserve(id);
    }

    /**
     * 修改
     * @param reserve
     * @return
     */
    @RequestMapping(value = "/updateReserve",method = RequestMethod.POST)
    public ResponseMessage updateReserve(@RequestBody Reserve reserve){
        return reserveService.updateReserve(reserve);
    }

    /**
     * 模糊查询
     * @param reserveSelectLike
     * @return
     */
    @RequestMapping(value = "/selectLike",method = RequestMethod.GET)
    public ResponseMessage selectLike(ReserveSelectLike reserveSelectLike){
        return reserveService.selectLike(reserveSelectLike);
    }


}
